#include    "Integer.h"
#include <iostream>
#include <sstream>


void        Integer::SetNum(int _num)
{
    data=_num;
}
const int&  Integer::GetNum() const
{
    return data;
}
const Integer&     Integer::operator=(const Integer& _num)
{
    data=_num.data;

    return  *this;
}

            Integer::Integer(const string& _num)
{
    stringstream out(_num);
    out >> data ;
}

Integer     Integer::operator+=(const Integer& _num)
{
    data += _num.data;

    return  *this;
}

Integer     Integer::operator-=(const Integer& _num)
{
    data -= _num.data;

    return  *this;
}

Integer     Integer::operator~() const
{
    Integer temp(~data);

    return  temp;
}

const Integer&  Integer::operator ^=(const Integer& _num)
{
    data^=_num.data;
    return *this;
}



Integer     Integer::operator*=(const  Integer& _num)
{
    data *= _num.data;

    return  *this;
}

Integer     Integer::operator%(const Integer& _num) const
{
    Integer temp( data % _num.GetNum() );

    return  temp;
}

bool        Integer::operator==(const Integer& _num)const
{
    return  data == _num.data;
}

bool        Integer::operator>=(const Integer& _num)const
{
    return  (operator>(_num) || operator==(_num));
}

bool        Integer::operator<=(const Integer& _num)const
{
    return  (operator<(_num) || operator==(_num));
}

bool        Integer::operator<(const Integer& _num)const
{
    if (data<_num.data && ! operator==(_num))
    {
       return true;
    }
    return false;
}

Integer&    Integer::operator++()
{
    ++data;
    return *this;
}

Integer    Integer::operator++(int)
{
    Integer copy(*this);

    ++data;
    return copy;
}

Integer&    Integer::operator--()
{
    --data;
    return *this;
}

Integer    Integer::operator--(int)
{
    Integer copy(*this);

    --data;
    return copy;
}

bool        Integer::operator>(const Integer& _num)const
{
    return _num.operator<(*this);
}

 Integer::operator string() const
{
    stringstream out;
    out << data;

    return out.str();
}


ostream&    operator<<(ostream& os, const Integer& _num)
{
    return os<<_num.GetNum();
}

istream&    operator>>(istream& is, Integer& _num)
{
    int temp;

    cout<<"enter your number"<<endl;
    is >> temp;
    _num.SetNum(temp);

    return is;
}
